﻿using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using PayService.Common;

namespace PayService.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class DIController : ControllerBase
    {
        public IRepository Repository = null;

        public DIController(IRepository repository)
        {
            Repository = repository;
        }


        [HttpGet]
        public ActionResult<string> GetAll([FromServices]ProductTotalizer productTotalizer)
        {
            IRepository repository = HttpContext.RequestServices.GetService(typeof(IRepository)) as IRepository;

            var anonymous = new { IRepository = Repository.GenerateGUID(), ProductTotalizer = productTotalizer.GenerateGUID() };

            return JsonConvert.SerializeObject(anonymous);
        }

    }
}